package cn.tedu.api;

/**
 * @author: Dsi
 * @date: 2021/11/12 16:30
 * @description:该类用于练习字符串的拼接
 */
public class TestString03 {
    public static void main(String[] args) {
        String s1="abcdefghijklmnopqrstuvwxyz";
        method1(s1);
        //method2(s1);
    }
    private static void method2(String s1) {
        String s2= "";
        long stat =System.currentTimeMillis();
        for (int i = 0; i < 10000; i++) {
            s2=s2+s1;
        }
        long stop=System.currentTimeMillis();
        System.out.println(stop-stat);
        System.out.println(s2);
    }

    private static void method1(String s1) {
        StringBuffer b=new StringBuffer();
        StringBuilder b2=new StringBuilder();

        long stat=System.currentTimeMillis();
        for (long i = 0; i < 9999999; i++) {
            //b.append(s1);
            b2.append(s1);
        }
        long stop=System.currentTimeMillis();
        System.out.println(stop-stat);
        //System.out.println(b);
        //System.out.println(b2);
    }
}
